class Solution(object):
    def mergeTwoLists(self, l1, l2):
        """
        :type l1: ListNode
        :type l2: ListNode
        :rtype: ListNode
        """
        if not l1 and not l2: return None
        if not l1 and l2: return l2
        if not l2 and l1: return l1
        if l1.val>=l2.val:  master, slave = l2, l1
        else: master, slave = l1, l2

        m = master
        s = slave
        while m.next:
            if s.val <= m.next.val:
                tmp = m.next
                m.next = s
                s = tmp
            m = m.next
        m.next = s
        return master